import { useMemo } from 'react'
import Title from '@components/title'
import { formatDate, formatMoney } from '@src/assets/js/tool'
import style from './index.module.less'
import OrderLine from '@components/orderLine'

// 格式化请求内容
function formatClaimValue (d) {
  const { desc, type } = d
  if (type === '标的收费') {
    return `${desc || ''}（争议金额：${formatMoney(d.dispute_amount)}）`
  } else if (type !== '仲裁费') {
    return `${desc || ''}（${type || ''} | ${formatMoney(d.fee_acceptance)}）`
  } else {
    return `${desc || ''}（${type || ''}）`
  }
}

function Main ({ data, anti }) {
  const statement = useMemo(() => {
    return data.statement ? data.statement : ''
  }, [data])
  if (data.items.length === 0) {
    return <span />
  }
  return (
    <div>
      <Title title={anti ? '反仲裁请求' : '仲裁请求'} sub={formatDate(data.create_datetime, 'YYYY-MM-DD')} />
      <div className={style.list}>
        {
          data.items.map((li, i) => {
            return (
              <OrderLine key={i} index={i + 1} value={formatClaimValue(li)} third />
            )
          })
        }
      </div>
      {
       !!statement && (
          <div>
            <Title title='事实与理由' />
            <div className={style.content}>
              {statement}
            </div>
          </div>
        )
      }
    </div> 
  )
}

export default Main
